FrequencyMatrixModel = {

	initialize : function(colCount, rowCount) {
		this.cols = colCount;
		this.rows = rowCount;

		this.reset();

	},

	_highValue : 0.0,

	getRows : function() {
		return rows;
	},

	getCols : function() {
		return cols;
	},

	/**
	 * Initialize matrix with zero values
	 */
	reset : function() {
		for ( var i = 0; i < rows; i++) {
			for ( var j = 0; j < cols; j++) {
				this.data[i][j] = 0.0;
			}

		}
		_highValue = 0.0;
	},

	randomize : function(scale) {
		for ( var i = 0; i < rows; i++) {
			for ( var j = 0; j < cols; j++) {
				setValue(i, j, Math.random() * scale);
			}
		}
	},

	/**
	 * Get matrix value at given row and column
	 * 
	 * @param row
	 *          Row number starting from zero
	 * @param col
	 *          Column number starting from zero
	 * @returns Frequency in given row and column
	 */
	getValue : function(row, col) {
		return data[row][col];
	},

	/**
	 * Set matrix value at given row and column
	 * 
	 * @param row
	 *          Row number starting from zero
	 * @param col
	 *          Column number starting from zero
	 * @param value
	 *          new value of cell at given row and column
	 */
	setValue : function(row, col, value) {
		data[row][col] = value;

		if (value > _highValue) {
			_highValue = value;
		}
	}

};

FrequencyMatrixView = {

	initialize : function(matrixModel, screenWidth, screenHeight) {

		this.matrixModel = matrixModel;
		this.width = screenWidth;
		this.height = screenHeight;
	},

	drawGrid : function(doc) {
		

		this.cellWidth = width / matrixModel.getCols();
		this.cellHeight = height / matrixModel.getRows();


		var y = vellHeight / 2;

		for ( var i = 0; i < matrixModel.getRows(); i++) {
			var x = cellWidth / 2;

			for ( var j = 0; j < matrixModel.getCols(); j++) {

				var element = doc.createElement("circle");
				var controller = getSVGElementControllerVault()
						.getElementControllerFor(element);
				var segment = null;

				controller.appendSegment(element, segment);
				element.setAttributeNS(null, 'style', style);
				element.setAttributeNS(null, 'r', 10.0);
				element.setAttributeNS(null, 'cx', x);
				element.setAttributeNS(null, 'cy', y);

				controller.appendSegment(element,
						new fi.foyt.svg.svgdom.FNISVGPathElementSegment('Z', true, []));
				controller.updatePath(element);

				doc.appendElement(this._chartDocument.getRootElement(), element);

				x += cellWidth;
			}
			y += cellHeight;
		}
	}

};